//
//  ViewController.m
//  项目二
//
//  Created by rimi on 16/3/14.
//  Copyright © 2016年 LiYunxiao. All rights reserved.
//

#import "ViewController.h"
#import <BmobSDK/Bmob.h>
#import <BmobSDK/BmobProFile.h>
#import "NewListTableViewCell.h"
#import "UIImageView+WebImage.h"
#import "Util.h"
@interface ViewController ()

@property(nonatomic,strong)NSString *dogIntro;
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSMutableArray *newsList;
@property(nonatomic, strong)NSString *string;
@property(nonatomic,strong)NSString *text;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
//    //构造上传文件路径数组
//    NSBundle *mainBundle = [NSBundle mainBundle];
//    NSString *path       = [mainBundle bundlePath];
//    NSString *path1 = [path stringByAppendingPathComponent:@"nv.jpg"];
//    NSString *path2 = [path stringByAppendingPathComponent:@"cncc.jpg"];
//    NSString *path3 = [path stringByAppendingPathComponent:@"test.txt"];
//    NSArray *array = @[path1,path2,path3];
//    
//    //上传文件
//    [BmobProFile uploadFilesWithPaths:array resultBlock:^(NSArray *pathArray, NSArray *urlArray,NSArray *bmobFileArray,NSError *error) {
//        //路径数组和url数组（url数组里面的元素为NSString）
//        if (error) {
//            NSLog(@"%@",error);
//        } else {
//            //路径数组和url数组（url数组里面的元素为NSString）
//            NSLog(@"pathArray %@ urlArray %@",pathArray,urlArray);
//            for (BmobFile* bmobFile in bmobFileArray ) {
//                NSLog(@"%@",bmobFile);
//            }
//        }
//    } progress:^(NSUInteger index, CGFloat progress) {
//        //index表示正在上传的文件其路径在数组当中的索引，progress表示该文件的上传进度
//        NSLog(@"index %lu progress %f",(unsigned long)index,progress);
//    }];
    //UILabel *labe = [[UILabel alloc]init];
//    NSBundle    *bundle = [NSBundle mainBundle];
//    NSString *fileString = [NSString stringWithFormat:@"%@/cs.txt" ,[bundle bundlePath] ];
//    BmobObject *obj = [[BmobObject alloc] initWithClassName:@"GameScore"];
//    BmobFile *file1 = [[BmobFile alloc] initWithFilePath:fileString];
//    [file1 saveInBackground:^(BOOL isSuccessful, NSError *error) {
//        //如果文件保存成功，则把文件添加到filetype列
//        if (isSuccessful) {
//            [obj setObject:file1  forKey:@"filetype"];
//            [obj saveInBackground];
//            //打印file文件的url地址
//            NSLog(@"file1 url %@",file1.url);
//        }else{
//            //进行处理
//        }
    //        //构造NSData
//    NSString *mainBundlePath = [[NSBundle mainBundle] bundlePath];
    NSData *data = UIImageJPEGRepresentation([UIImage imageNamed:@"nv.jpg"], 0.5);
//    //上传文件
    [BmobProFile uploadFileWithFilename:@"9jpg" fileData:data block:^(BOOL isSuccessful, NSError *error, NSString *filename, NSString *url,BmobFile *bmobFile) {
        if (isSuccessful) {
            //打印文件名
            NSLog(@"filename %@",filename);
            //打印url
            NSLog(@"url %@",url);
            NSLog(@"bmobFile:%@\n",bmobFile);
        } else {
            if (error) {
                NSLog(@"error %@",error);
            }
        }
    } progress:^(CGFloat progress) {
        //上传进度，此处可编写进度条逻辑
        NSLog(@"progress %f",progress);
    }];
    //构造上传文件data字典数组
//    NSBundle *mainBundle = [NSBundle mainBundle];
//    NSString *path       = [mainBundle bundlePath];
//    NSString *path1 = [path stringByAppendingPathComponent:@"nv.jpg"];
//    NSString *path2 = [path stringByAppendingPathComponent:@"cncc.jpg"];
//    NSString *path3 = [path stringByAppendingPathComponent:@"test.txt"];
//    
//    NSData* data1 = [NSData dataWithContentsOfFile:path1];
//    NSData* data2 = [NSData dataWithContentsOfFile:path2];
//    NSData* data3 = [NSData dataWithContentsOfFile:path3];
//    
//    NSDictionary *dic1 = [[NSDictionary alloc] initWithObjectsAndKeys:@"nv.jpg",@"filename",data1,@"data",nil];
//    NSDictionary *dic2 = [[NSDictionary alloc] initWithObjectsAndKeys:@"cncc.jpg",@"filename",data2,@"data",nil];
//    NSDictionary *dic3 = [[NSDictionary alloc] initWithObjectsAndKeys:@"test.txt",@"filename",data3,@"data",nil];
//    
//    NSArray *array = @[dic1,dic2,dic3];
//    
//    //上传文件，dataArray 数组中存放NSDictionary，NSDictionary里面的格式为@{@"filename":@"你的文件名",@"data":文件的data}
//    [BmobProFile uploadFilesWithDatas:array resultBlock:^(NSArray *filenameArray, NSArray *urlArray, NSArray *bmobFileArray,NSError *error) {
//        if (error) {
//            NSLog(@"%@",error);
//        } else {
//            //路径数组和url数组（url数组里面的元素为NSString）
//            NSLog(@"fileArray %@ urlArray %@",filenameArray,urlArray);
//            for (BmobFile* bmobFile in bmobFileArray ) {
//                NSLog(@"%@",bmobFile);
//            }
//        }
//    } progress:^(NSUInteger index, CGFloat progress) {
//        //index表示正在上传的文件其路径在数组当中的索引，progress表示该文件的上传进度
//        NSLog(@"index %lu progress %f",(unsigned long)index,progress);
//    }];
//    
    

}




@end
